package com.g.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class RibbonService {
	
	private static final String REST_URL_PREFIX = "http://providerSayhello";
	
	@Value("${server.port}")
	private String port;
	
	@Autowired
	RestTemplate restTemplate;
	
	@HystrixCommand(defaultFallback = "sayError")
	public String sayHello() {
		return restTemplate.getForObject(REST_URL_PREFIX + "/home", String.class);
	}
	public String sayError() {
		return "oh~service,error!";
	}
}
